import React, { Component } from 'react'
import { Route, Switch, Link, withRouter } from 'react-router-dom'

import Home from './views/Home'
import About from './views/About'

@withRouter
class App extends Component {
  render() {
    return (
      <div>
        <Link to="/home">Home</Link> --
        <Link to="/about">About</Link>
        <hr />
        {/* children回调函数的方式来渲染，不关心path和地址栏是否匹配，它都会显示出来，显示和隐藏交给CssTransition组件 */}
        <Route path="/home" children={router => <Home {...router} />} />
        <Route path="/about" children={router => <About {...router} />} />
      </div>
    )
  }
}

export default App
